//
// Created by tang on 23-4-1.
//

#ifndef VIEW_BASE_HPP
#define VIEW_BASE_HPP

#include "sdk_config.h"
#include "resource/resource.hpp"
#include "service/render_service.hpp"

class bindable_base;

class PI_API ui_view {
public:
    virtual ~ui_view();

    virtual void draw() = 0;

    virtual void bind(bindable_base *data) = 0;
};

#define RESOURCE_VIEW(out_var, res_path) \
do {\
    auto const content = MY_RESOURCE->get_file_content(res_path); \
    if (!content.empty()) \
        out_var = ServiceManager::instance()->request_service<IRenderService>()->create_view_from_data(content.data(), content.size()); \
} while(0)

#endif /* VIEW_BASE_HPP */
